<template>
  <el-container style="height: 100vh">
    <el-aside width="220px" class="aside">
      <div class="logo">
        <el-icon><Monitor /></el-icon>
        <span class="title">Visual协同</span>
      </div>
      <el-menu
        :default-active="$route.path"
        class="menu"
        router
        background-color="#2d3a4b"
        text-color="#fff"
        active-text-color="#409EFF"
      >
        <el-menu-item index="/admin/users">
          <el-icon><User /></el-icon>
          <span>用户管理</span>
        </el-menu-item>
        <el-menu-item index="/admin/pictures">
          <el-icon><Picture /></el-icon>
          <span>图片管理</span>
        </el-menu-item>
        <el-menu-item index="/admin/categories">
          <el-icon><CollectionTag /></el-icon>
          <span>分类管理</span>
        </el-menu-item>
        <el-menu-item index="/admin/spaces">
          <el-icon><Document /></el-icon>
          <span>空间管理</span>
        </el-menu-item>
        <!-- 空间分析 -->
        <el-menu-item index="/admin/space_analysis">
          <el-icon><PieChart /></el-icon>
          <span>空间分析</span>
        </el-menu-item>
      </el-menu>
      <el-button class="logout-btn" type="primary" plain @click="goHome"> 返回首页 </el-button>
    </el-aside>
    <el-container>
      <el-main class="main">
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup>
import { useRouter } from 'vue-router'
const router = useRouter()
const goHome = () => {
  router.push('/')
}
</script>

<style scoped>
.aside {
  background: #2d3a4b;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.logo {
  display: flex;
  align-items: center;
  height: 64px;
  padding-left: 24px;
  font-size: 22px;
  font-weight: bold;
  background: #223047;
  margin-bottom: 10px;
  letter-spacing: 2px;
}
.logo .el-icon {
  margin-right: 10px;
  font-size: 26px;
}
.title {
  vertical-align: middle;
}
.menu {
  border-right: none;
  flex: 1;
}
.logout-btn {
  margin: 24px;
  margin-top: auto;
}
.main {
  background: #f5f7fa;
  padding: 24px;
  min-height: 100vh;
  box-sizing: border-box;
}
</style>
